package realQuestion.xima;

public class Main1 {


    public int maxAbsoluteSum (int[] nums)
    {
        if(nums.length==0){
            return  0;
        }
        int max = Integer.MIN_VALUE;
        int[] dp = new int[nums.length];
        dp[0]=Math.abs(nums[0]);
        int sum=nums[0];
        for (int i = 1; i < nums.length; i++) {
            sum+=nums[i];
            dp[i] = Math.max(Math.abs(sum), Math.abs(nums[i] ) );
            dp[i] = Math.max(Math.abs(nums[i-1]+ nums[i]), dp[i] );
            max = Math.max(max, dp[i]);

        }

        return  max>dp[0]?max:dp[0];



    }

    public static void main(String[] args) {
        Main1 main1 = new Main1();
        int[] arr={2,-5,1,-4,3,-2};
        System.out.println(main1.maxAbsoluteSum(arr));
    }
}
